﻿
import com.darronschall.DynamicRegistration;
import flash.geom.Point;

/**
 * ...
 * @author wangjun
 */
class A2.utils.uRegPoint 
{
	
	public function uRegPoint() 
	{
		
	}
	public static function convert(oriMC:MovieClip,tarMC:MovieClip,pt:Point):Point {
		
		oriMC._parent.localToGlobal(pt);
		tarMC.globalToLocal(pt); 
		return pt;
	}
	public static function init(mc:MovieClip,pt:Point) 
	{
		DynamicRegistration.initialize(mc);
		if(pt==null){
			mc.setRegistration(mc._width / 2, mc._height / 2);		
		}else {
			mc.setRegistration(Number(pt.x), Number(pt.y));	
		}
	}
	//------------------- Left ----------------------- 
	public static function toLeftTop(mc:MovieClip ) {
		init(mc,new Point(0,0));
	}
	public static function toLeftCenter(mc:MovieClip ) {
		init(mc,new Point(0,mc._height/2));
	}
	public static function toLeftBottom(mc:MovieClip ) {
		init(mc,new Point(0,mc._height));
	}
	//------------------- Middle ----------------------- 
	public static function toMiddleTop(mc:MovieClip ) {
		init(mc,new Point(mc._width/2,0));
	}
	public static function toMiddleCenter(mc:MovieClip ) {
		init(mc,new Point(mc._width/2,mc._height/2));
	}
	public static function toMiddleBottom(mc:MovieClip ) {
		init(mc,new Point(mc._width/2,mc._height));
	}
	//------------------- Right ----------------------- 
	public static function toRightTop(mc:MovieClip ) { 		
		init(mc,new Point(mc._width,0));
	} 
	public static function toRightCenter(mc:MovieClip ) { 		
		init(mc,new Point(mc._width,mc._height/2));
	} 
	public static function toRightBottom(mc:MovieClip ) { 		
		init(mc,new Point(mc._width,mc._height));
	} 
	
	
}